class Dispatch(object):
    """
    单个产品调度
    """
    def __init__(self, product_id, route_nums, equip_names,
                 start_times, duration_times, end_times):
        self.product_id = product_id
        self.route_nums = route_nums
        self.equip_names = equip_names
        self.start_times = start_times
        self.duration_times = duration_times
        self.end_times = end_times

    def output(self):
        print("product id: ", self.product_id, end=' ')
        print("route_nums: ", self.route_nums, end=' ')
        print("equip_names: ", self.equip_names, end=' ')
        print("start_times: ", self.start_times, end=' ')
        print("duration_times: ", self.duration_times, end=' ')
        print("end_times: ", self.end_times, end=' ')
        print()

    def write_ans(self):
        n = len(self.route_nums)
        assert len(self.route_nums) == n, "ans is illegal"
        assert len(self.equip_names) == n, "ans is illegal"
        assert len(self.start_times) == n, "ans is illegal"
        assert len(self.duration_times) == n, "ans is illegal"
        assert len(self.end_times) == n, "ans is illegal"

        rows = []
        for i in range(n):
            row = [
                self.product_id,
                self.route_nums[i],
                self.equip_names[i],
                self.start_times[i] / 60,
                self.duration_times[i] / 60,
                self.end_times[i] / 60
            ]
            row = list(map(str, row))
            rows.append(','.join(row))

        return rows

class Period(object):
    def __init__(self, product_id, route_id, equip_name,
                 start_time, duration_time, end_time):
        self.product_id = product_id
        self.route_id = route_id
        self.equip_name = equip_name
        self.start_time = start_time
        self.duration_time = duration_time
        self.end_time = end_time

    def write_ans(self):
        rows = []
        row = [
            self.product_id,
            self.route_id,
            self.equip_name,
            self.start_time / 60,
            self.duration_time / 60,
            self.end_time / 60
        ]
        row = list(map(str, row))
        rows.append(','.join(row))

        return rows
